package 多线程.虚假唤醒;

import java.util.concurrent.locks.LockSupport;

/**
 * 
 */
public class parkUnpark05 {
    //不需要在锁块中
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            int i = 0;
//            while (true){
//                System.out.println(i++);
//                try {
//                    Thread.sleep(500);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }
            System.out.println(1);
        });
        //只能自己park自己
        //但是可以别人unpark另一个人
        //所以下边的park失效
        thread.start();
        LockSupport.park();
//        LockSupport.park(thread);
//        LockSupport.unpark(Thread.currentThread());
        System.out.println("-----------");

        LockSupport.park(thread);
        LockSupport.park(thread);
        LockSupport.park(thread);
    }

}
